#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(SimEvent)

#----------------------------------------------------------------------------
## Setup ROOT include directories and compile definitions
##
list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
find_package(ROOT REQUIRED)

# check ROOT version
if(ROOT_FOUND)
  STRING(REGEX MATCH "6.*" VERSION6MATCH ${ROOT_VERSION})
  if(NOT VERSION6MATCH)
    message(FATAL_ERROR "--> ERROR: ROOT 6 is required but not found")
  endif()
endif()

include(${ROOT_USE_FILE})

#----------------------------------------------------------------------------
# Locate sources and headers for this project
#
#include_directories(${Geant4_INCLUDE_DIR})
include_directories(${ROOTSYS}/include)

MESSAGE( ${PROJECT_SOURCE_DIR} )
include_directories(${PROJECT_SOURCE_DIR}/source)

#----------------------------------------------------------------------------
# Generate dictionaries, add ROOT libraries properties
ROOT_GENERATE_DICTIONARY(SimEvent ${PROJECT_SOURCE_DIR}/source/SimEvent.h LINKDEF ${PROJECT_SOURCE_DIR}/source/Linkdef.h)
add_library(SimEventDict SHARED SimEvent.cxx)
set(libsuffix .so)
set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES} SUFFIX ${libsuffix})
set_target_properties(SimEventDict PROPERTIES ${ROOT_LIBRARY_PROPERTIES})
target_link_libraries(SimEventDict ${ROOT_LIBRARIES})
